package net.chathu.airgw.packets.gw.clientpackets 
{
	import net.chathu.airgw.Config;
	import net.chathu.airgw.model.Room;
	import net.chathu.airgw.model.User;
	import net.chathu.airgw.packets.gw.serverpackets.ErrorNoSuchChannelPacket;
	import net.chathu.airgw.util.ByteArrayUtil;
	/**
	 * ...
	 * @author ze
	 */
	public class CMDGWLeaveConfRoom extends IRCReceivablePacket 
	{
		
		public function CMDGWLeaveConfRoom() 
		{
			
		}
		
		override public function execute():void {
			var room:Room = sessionData.chatData.rooms.getRoomByName(data[1]);
			if (room) {
				//"4"=leave conf reoom
				var yourUser:User = sessionData.chatData.users.getUser(sessionData.chatData.userId) as User;
				sendToChat(ByteArrayUtil.convertParams(["m","messages","4","0",yourUser.regId,room.inviteId]));
			} else {
				sendToClient(new ErrorNoSuchChannelPacket(data[1]));
			}
		}
		
		public static function getShortUsageDescription():String {
			return "Kilépés konferencia szobából";
		}
		
		public static function getUsageDescription():String {
			return "Példa:\n" +
				"/gwleaveconfroom gipsz_jakab_szobája\n\n" +
				"Eredmény:\n" + 
				"Sikeresen kiléptél a gipsz_jakab_szobája szobából.";
		}
	}

}